using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using emp.BLL.SysManage;
using emp.ProcessFlow;
using emp.Model;
using emp.Model.SysManage;
using emp.BLL;
using emp.Utility;
using emp.Model.SysManage;

public partial class QuestionnaireAdd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        hidden_type.Value = "R";
        if (Request["type"] != null && Request["type"].ToString().Equals(""))
        {
            hidden_type.Value = Request["type"].ToString();
        }
       
    }


    protected void btnSubmit_Click(object sender, EventArgs e)
    {
     
        QuestionnaireInfo qainfo = new QuestionnaireInfo();
        qainfo.QunaireName = this.qunaire_name.Text.Trim();
        qainfo.QunaireType = hidden_type.Value.ToString();

      
        qainfo.QunaireNotes = this.qunaire_notes.Text.Trim();
        qainfo.QunaireStatus = "N";
        qainfo.CreateUser = 1;
        try
        {
            if (HttpContext.Current.Session["USER_KEY"] != null)
            {
                UserInfo myUserInfo = (UserInfo)HttpContext.Current.Session["USER_KEY"];
                qainfo.CreateUser = myUserInfo.UserID;
            }
           
        }
        catch { }

        Questionnaire qu = new Questionnaire();
        qainfo.QunaireCode = "";
    qainfo.QunaireCode = StringUtil.getCode(hidden_type.Value.ToString(), qu.getCode() + 1);
       // Response.Write("ssssssssssss" + qainfo.QunaireCode);
        try
        {
           
            qu.Insert(qainfo);
        }
        catch (Exception err)
        {
            Response.Write(err.ToString());
        }
       HttpContext.Current.Response.Redirect("QuestionnaireList.aspx");
    }

    protected void qunaire_type_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}
